<?php
if( ! defined('BASEPATH')) exit('No direct script access allowed');

class Comment_model extends CI_Model
{
	public function __construct()
	{
		parent::__construct();
	}
	
	public function all_comments($task_id){
		$this->db->select('tasks.id');
		$this->db->from('tasks');
		$this->db->where('tasks.project_id',$task_id);
		$tid = $this->db->get()->result();
		
		foreach($tid as $t){
		$this->db->select('task_notes.*,task.title');
		$this->db->from('task_notes');
		$this->db->where('task_notes.task_id',$t->id);
		$this->db->join('task','task.id = task_notes.task_id');
		return $this->db->get()->result();
		}			
	}
	
	public function get_tasks_by_projectid($project_id){		
		$this->db->select('id,title');
		$this->db->from('tasks');
		$this->db->where('project_id',$project_id);
		return $this->db->get()->result();
	}
	
	public function get_all_projects(){
		$this->db->select('id,name');
		$this->db->from('projects');
		return $this->db->get()->result();
	}
	
}

